<script type="text/javascript">
	function doSearchTranDriver(value) {
		
	}
	
	//表格查询  
	function reloadTranDriver() {
		var params = tranDriver_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		tranDriver_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		tranDriver_list.datagrid('unselectAll');
		tranDriver_list.datagrid('uncheckAll');
	}


	function addTranDriver() {
		createFromWindow("新增信息", "tranDriver.do?editTranDriver", "tranDriver.do?saveTranDriver",
				function(data) {
					reloadTranDriver();
				});
	}
	
	function deleteTranDriver() {
		var rows = tranDriver_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('tranDriver.do?deleteTranDriverItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadTranDriver();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editTranDriver() {
		var rows = tranDriver_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "tranDriver.do?editTranDriver&tranDriverId=" + rows[0].id,
					"tranDriver.do?saveTranDriver", function(data) {
						reloadTranDriver();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookTranDriver(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = tranDriver_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "tranDriver.do?editTranDriver&tranDriverId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditTranDriver(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = tranDriver_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "tranDriver.do?editTranDriver&tranDriverId=" + id,
					"tranDriver.do?saveTranDriver", function(data) {
						reloadTranDriver();
					},true);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendTranDriver() {
		printLog('发送');
	}
	
	function operationsDeleteTranDriver(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('tranDriver.do?deleteTranDriverItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadTranDriver(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
</script>

<#assign operations = "[\{shiro:'transportation:tranDriver:refresh',onClick:'operationsLookTranDriver',src:'static/jmax/images/notes/note.png',title:'查看'},
	   					\{shiro:'transportation:tranDriver:edit',onClick:'operationsEditTranDriver',src:'static/jmax/images/notes/note_edit.png',title:'编辑'},
	   					\{shiro:'transportation:tranDriver:send',onClick:'operationsSendTranDriver',src:'static/jmax/images/notes/note_go.png',title:'发送'},
	   					\{shiro:'transportation:tranDriver:delete',onClick:'operationsDeleteTranDriver',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="tranDriver_list" toolbar="#tranDriverlist_search" idField="id" operations="${operations!}"
			 url="tranDriver.do?loadList" rownumbers="true"
			 item="com.xdtech.transportation.vo.TranDriverItem"/>
		
		<div id="tranDriverlist_search">
			<div id="tranDriver_toolbar" style="height: auto">
				
				<@eu.linkbutton showName="新增" shiro="transportation:tranDriver:add" iconCls="icon-add" onclick="addTranDriver()"/>
				<@eu.linkbutton showName="删除" shiro="transportation:tranDriver:delete" iconCls="icon-remove" onclick="deleteTranDriver()"/>
				<@eu.linkbutton showName="编辑" shiro="transportation:tranDriver:edit" iconCls="icon-edit" onclick="editTranDriver()"/>
				<@eu.linkbutton showName="刷新" shiro="transportation:tranDriver:refresh" iconCls="icon-reload" onclick="reloadTranDriver()"/>
				
			</div>
		</div>
	</div>
</div>